package mylab.starters.mybatis.config;


import com.baomidou.mybatisplus.annotation.DbType;
import lombok.Getter;
import mylab.base.constants.DbConst;
import mylab.starters.mybatis.config.dynamicTable.DynamicTableProperties;
import mylab.starters.mybatis.config.foreignKey.ForeignKeyProperties;
import mylab.starters.mybatis.config.tenant.TenantProperties;
import mylab.utils.spring.constants.PropertyConst;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;


@Getter
@ConfigurationProperties(prefix = DbProperties.PREFIX)
public class DbProperties {
    public static final String PREFIX = PropertyConst.PROPERTIES_PREFIX + ".db";

    /**
     * 数据库类型,默认mysql
     */
    private DbType dbType = DbType.MYSQL;

    /**
     * 溢出总页数后是否进行处理,默认不处理
     */
    private boolean overflow = false;

    /**
     * 单页分页条数限制，默认值1000条
     */
    private long pageMaxLimit = DbConst.PAGE_MAX_LIMIT;

    /**
     * 是否启用 乐观锁插件
     */
    private boolean enableOptimisticLocker = true;

    /**
     * 是否启用 防止全表更新与删除插件
     */
    private boolean enableBlockAttack = false;

    /**
     * 是否启用  sql性能规范插件
     */
    private boolean enableIllegalSql = false;

    /**
     * 是否启用数据变更记录
     */
    private boolean enableDataChangeRecorder = true;

    /**
     * 是否启用数据权限
     */
    private boolean enableDataScope = false;

    /**
     * 是否启用数据权限
     */
    private boolean enableDataPermission = false;

    @NestedConfigurationProperty
    private TenantProperties tenant = new TenantProperties();

    @NestedConfigurationProperty
    private DynamicTableProperties dynamicTable = new DynamicTableProperties();

    @NestedConfigurationProperty
    private ForeignKeyProperties foreignKey = new ForeignKeyProperties();

}


